home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 726-750 / 741 / rkrm_devices / rkrm_devices.lha / Resources / Get_Filesys.c < prev    next >
C/C++ Source or Header  |  1992-09-03  |  3KB  |  92 lines

  1. /*
  2.  * Copyright (c) 1992 Commodore-Amiga, Inc.
  3.  * 
  4.  * This example is provided in electronic form by Commodore-Amiga, Inc. for 
  5.  * use with the "Amiga ROM Kernel Reference Manual: Devices", 3rd Edition, 
  6.  * published by Addison-Wesley (ISBN 0-201-56775-X).
  7.  * 
  8.  * The "Amiga ROM Kernel Reference Manual: Devices" contains additional 
  9.  * information on the correct usage of the techniques and operating system 
  10.  * functions presented in these examples.  The source and executable code 
  11.  * of these examples may only be distributed in free electronic form, via 
  12.  * bulletin board or as part of a fully non-commercial and freely 
  13.  * redistributable diskette.  Both the source and executable code (including 
  14.  * comments) must be included, without modification, in any copy.  This 
  15.  * example may not be published in printed form or distributed with any
  16.  * commercial product.  However, the programming techniques and support
  17.  * routines set forth in these examples may be used in the development
  18.  * of original executable software products for Commodore Amiga computers.
  19.  * 
  20.  * All other rights reserved.
  21.  * 
  22.  * This example is provided "as-is" and is subject to change; no
  23.  * warranties are made.  All use is at your own risk. No liability or
  24.  * responsibility is assumed.
  25.  *
  26.  *****************************************************************************
  27.  *
  28.  *
  29.  * Get_Filesys.c
  30.  *
  31.  * Example of examining the FileSysRes list
  32.  *
  33.  * Compile with SAS 5.10  lc -b1 -cfistq -v -y -L
  34.  *
  35.  * Run from CLI only
  36.  */
  37.  
  38. #include <exec/types.h>
  39. #include <exec/memory.h>
  40. #include <dos/dos.h>
  41. #include <resources/filesysres.h>
  42.  
  43. #include <clib/exec_protos.h>
  44.  
  45. #include <stdio.h>
  46.  
  47. #ifdef LATTICE
  48. int CXBRK(void) { return(0); }  /* Disable SAS CTRL/C handling */
  49. int chkabort(void) { return(0); }  /* really */
  50. #endif
  51.  
  52. struct FileSysResource *FileSysResBase = NULL;
  53.  
  54. void main(int argc, char **argv)
  55. {
  56.  
  57. struct FileSysEntry *fse;
  58. int x;
  59.  
  60. /* NOTE - you should actually be in a Forbid while accessing any
  61.  * system list for which no other method of arbitration is available.
  62.  * However, for this example we will be printing the information
  63.  * (which would break a Forbid anyway) so we won't Forbid.
  64.  * In real life, you should Forbid, copy the information you need,
  65.  * Permit, then print the info.
  66.  */
  67. if (!(FileSysResBase = (struct FileSysResource *)OpenResource(FSRNAME)))
  68.     printf("Cannot open %s\n",FSRNAME);
  69. else
  70.     {
  71.     for ( fse = (struct FileSysEntry *)FileSysResBase->fsr_FileSysEntries.lh_Head;
  72.           fse->fse_Node.ln_Succ;
  73.           fse = (struct FileSysEntry *)fse->fse_Node.ln_Succ)
  74.          {
  75.          /* An A3000 running V34 does not have the name field filled in. */
  76.          /* An A2000 running V34 with an A590/2091 controller also does  */ 
  77.          /* not have the name field filled in.                           */
  78.          if(fse->fse_Node.ln_Name)
  79.              printf("Found filesystem creator: %s\n",fse->fse_Node.ln_Name);
  80.  
  81.          printf("                 DosType: ");
  82.          for (x=24; x>=8; x-=8)
  83.               putchar((fse->fse_DosType >> x) & 0xFF);
  84.  
  85.          putchar((fse->fse_DosType & 0xFF) + 0x30);
  86.  
  87.          printf("\n                 Version: %d",(fse->fse_Version >> 16));
  88.          printf(".%ld\n\n",(fse->fse_Version & 0xFFFF));
  89.          }
  90.      }
  91. }
  92.